package com.efounder.adapter;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import com.efounder.fragment.MallCartFragment;
import com.efounder.fragment.MallMineFragment;
import com.efounder.fragment.MallRecommendFragment;

/**
 * Created by will on 18-1-5.
 */

public class MallPagerAdapter extends FragmentPagerAdapter {

    private String[] titles;

    public MallPagerAdapter(FragmentManager fm, String[] titles) {
        super(fm);
        this.titles = titles;
    }

    @Override
    public Fragment getItem(int position) {
        if (position == 0) {
            return new MallRecommendFragment();
        }else if (position == 1){
            return new MallCartFragment();
        }else if (position == 2){
            return new MallMineFragment();
        }
        return null;
    }

    @Override
    public int getCount() {
        return titles.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }
}
